Skip to content

build: fall back to previous image version on release PRs#12848

Merged
meltsufin merged 16 commits intomainfrom
release-please--fix-12825
Apr 21, 2026
Merged

build: fall back to previous image version on release PRs#12848
meltsufin merged 16 commits intomainfrom
release-please--fix-12825

Conversation

@meltsufin
Copy link
Copy Markdown
Member

@meltsufin meltsufin commented Apr 18, 2026

The library generation pipeline fails on release PRs because it attempts to pull a Docker image version that has not yet been built or pushed to the registry.

This PR adds a fallback mechanism in hermetic_library_generation.sh to use the previous version of the image from the main branch if the requested version fails to pull on a release PR.

To verify this in CI, this branch is named with the prefix 'release-please--' to simulate a release PR.

Fixes #12825

@meltsufin meltsufin requested a review from a team as a code owner April 18, 2026 02:03
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a fallback mechanism for the hermetic library generation script. When a release PR branch is detected, the script attempts to pull the specified Docker image; if it fails, it tries to extract and use the image tag from the target branch's workflow configuration. The review feedback suggests improving the robustness of the tag extraction logic to better handle potential multiple matches, comments, or colons within the YAML file.

Comment thread sdk-platform-java/.github/scripts/hermetic_library_generation.sh Outdated
@meltsufin meltsufin force-pushed the release-please--fix-12825 branch from 6880d59 to def6f2d Compare April 18, 2026 02:16
The library generation pipeline fails on release PRs because it attempts to pull a Docker image version that has not yet been built or pushed to the registry.

This PR adds a fallback mechanism in hermetic_library_generation.sh to use the previous version of the image from the main branch if the requested version fails to pull on a release PR.

To verify this in CI, this branch is named with the prefix 'release-please--' to simulate a release PR.

Fixes #12825
@meltsufin
Copy link
Copy Markdown
Member Author

Fallback validated in a separate release simulation PR #12849:

+ [[ release-please--simulation =~ ^release-please-- ]]
+ echo 'Detected release PR branch: release-please--simulation'
+ docker pull gcr.io/cloud-devrel-public-resources/java-library-generation:9.99.9
Detected release PR branch: release-please--simulation
Error response from daemon: manifest for gcr.io/cloud-devrel-public-resources/java-library-generation:9.99.9 not found: manifest unknown: Failed to fetch "9.99.9"
+ echo 'Image not found for version 9.99.9. Falling back to previous version from main.'
Image not found for version 9.99.9. Falling back to previous version from main.
++ git show main:.github/workflows/hermetic_library_generation.yaml
++ grep -m 1 '^[[:space:]]*image_tag:'
++ cut -d : -f 2-
++ cut -d '#' -f 1
++ xargs
+ previous_tag=2.71.0
+ '[' -n 2.71.0 ']'
+ echo 'Using previous image version: 2.71.0'
+ image_tag=2.71.0
Using previous image version: 2.71.0
++ id -u
++ id -g
++ pwd
+ docker run --rm -u 1001:1001 -v /home/runner/work/google-cloud-java/google-cloud-java:/workspace -v /tmp/tmp.dG9h7KnPTo:/workspace/googleapis -e GENERATOR_VERSION=2.71.0 gcr.io/cloud-devrel-public-resources/java-library-generation:2.71.0 --generation-config-path=/workspace/generation_config.yaml --library-names= --api-definitions-path=/workspace/googleapis
Unable to find image 'gcr.io/cloud-devrel-public-resources/java-library-generation:2.71.0' locally
2.71.0: Pulling from cloud-devrel-public-resources/java-library-generation

Comment thread sdk-platform-java/.github/scripts/hermetic_library_generation.sh Outdated
@meltsufin meltsufin requested a review from suztomo April 20, 2026 15:45
Comment thread sdk-platform-java/.github/scripts/hermetic_library_generation.sh Outdated

# run hermetic code generation docker image.
# Attempt to pull the image to see if it exists on release PRs.
if [[ "$current_branch" =~ ^release-please-- ]]; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could create release-please PRs from CLI as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine, as long as the branch prefix is release-please--.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that means we have to remember using release-please-- as the branch name, is there any harm we do this for every branches?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't have to use the Release Please CLI going forward which should eliminate the need to remember the branch prefix. The risk of always falling back is that if someone configures and invalid generator version, they won't get a CI failure as feedback.

Copy link
Copy Markdown
Member

@suztomo suztomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving but please consider whether to use the "latest" tag.

Comment thread sdk-platform-java/.github/scripts/hermetic_library_generation.sh Outdated
@meltsufin
Copy link
Copy Markdown
Member Author

Approving but please consider whether to use the "latest" tag.

@suztomo I think using the version in the target branch is more robust because it allows the code to support multiple branches with different versions of the generator.

@meltsufin meltsufin requested a review from blakeli0 April 21, 2026 00:53
@meltsufin meltsufin force-pushed the release-please--fix-12825 branch from 9a162ab to ef92609 Compare April 21, 2026 02:01
Comment thread generation_config.yaml
@@ -1,4 +1,3 @@
gapic_generator_version: 2.70.0
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blakeli0 Note that I'm removing this version declaration because it's confusing as it doesn't get updated, and it's not used anyway.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. We used to update this version in the daily generation PR to trigger a full generation, but we always use the latest snapshot version now after monorepo migration.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you intend to fix this file in the split repositories?

E.g, https://github.com/googleapis/java-firestore/blob/main/generation_config.yaml#L1

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's OK to wait until the other repos migrate to the monorepo.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this is resulted from monorepo migration. I don't think we want to do it for split repos.

@meltsufin meltsufin added the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 21, 2026
@meltsufin meltsufin added kokoro:force-run Add this label to force Kokoro to re-run the tests. and removed kokoro:run Add this label to force Kokoro to re-run the tests. labels Apr 21, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 21, 2026
@meltsufin meltsufin added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 21, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 21, 2026
ENV OS_ARCHITECTURE="linux-x86_64"

# {x-version-update-start:gapic-generator-java:current}
ENV GENERATOR_VERSION="2.71.0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sdk-platform-java/hermetic_build/common/model/generation_config.py has a method __set_generator_version that checks if the gapic_generator_version is specified in the YAML file. If it is not specified in the YAML, the code falls back to reading the GENERATOR_VERSION env var.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. We are already setting it in the CI hermetic_library_generation.yaml though, so this is for scenarios that are not triggered through CI?

Comment thread generation_config.yaml
@@ -1,4 +1,3 @@
gapic_generator_version: 2.70.0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. We used to update this version in the daily generation PR to trigger a full generation, but we always use the latest snapshot version now after monorepo migration.

@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

@meltsufin meltsufin added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 21, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 21, 2026
@meltsufin meltsufin merged commit 3d06cba into main Apr 21, 2026
120 of 124 checks passed
@meltsufin meltsufin deleted the release-please--fix-12825 branch April 21, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Library-generation fails on release PRs

5 participants